﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;

namespace SharingCenter.Web.Classes.Accounts
{
    using SharingCenter.Web.Classes.enums;
    public class RoleOperations
    {
        public static void AddUserToRole(string username, WebsiteRole role)
        {
            string roleName = role.ToString().ToLower();
            if (!Roles.RoleExists(roleName))
            {
                Roles.CreateRole(roleName);
            }

            Roles.AddUserToRole(username, roleName);
        }

        public static bool IsUserAdmin(string username)
        {
            try
            {
                return Roles.IsUserInRole(username, WebConsts.GENERAL_ADMIN_ROLENAME);
            }
            catch { return false; }
        }
    }
}
